function useFlagFormatter(value, row) {
    var html = "";
	if (row.openFlag == 1) {
        html = "<span class='text-success'>启用 </span>&nbsp;&nbsp;&nbsp;&nbsp;";
        html += "<button id='btn_edit' type='button' onclick='_stop("+row.rowId+", "+row.openFlag+", \""+row.raiderType+"\");'    class='btn btn-default btn-sm '><span class='glyphicon glyphicon-stop'></span>停用</button>";
        return html;
    } else {
        html = "<span class='text-warning'>停用 </span>&nbsp;&nbsp;&nbsp;&nbsp;";
        html += "<button id='btn_edit' type='button' onclick='_stop("+row.rowId+", "+row.openFlag+", \""+row.raiderType+"\");'    class='btn btn-default btn-sm '><span class='glyphicon glyphicon-ok'></span>启用</button>";
        return html;
    }
}

var tableIndex = 0;
// 弹出添加的窗口
function add(parentId){
    tableIndex = layer.open({
 	  	type: 2,
	 	title: "添加攻略类型",
 	  	closeBtn: 1,
 	  	shadeClose: true,
 	  	area: ['420px', '265px'],
 	  	content: JSSYSMANAGERV1 + '/raiderType/toAddRaiderType?rowId=0&parentId='+parentId,
 	  	btn: ["确 认","关 闭"], 
 	  	yes: function(index, layero){
	    	var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：
	        iframeWin.add();
		}
	});
}
// 弹出添加的窗口      修改功能
function _update(rowId,parentId){
    tableIndex = layer.open({
 	  	type: 2,
 	  	title: "修改攻略类型",
 	  	closeBtn: 1,
 	  	shadeClose: true,
 	  	area: ['420px', '265px'],
 	  	content: JSSYSMANAGERV1 + '/raiderType/toAddRaiderType?rowId='+rowId+'&parentId='+parentId,
 	  	btn: ["确 认","关 闭"], 
 	  	yes: function(index, layero){
	    	var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：
	        iframeWin.add();
		}
	});
}
//停用（启用）
function _stop(rowId, openFlag, raiderType){
	var descStr = "【停用】<a style='color:red'>"+'"'+raiderType+'"'+'</a>';
	if (openFlag == 0) {
		descStr = "【启用】<a style='color:red'>"+'"'+raiderType+'"'+'</a>';
	}
    openFlag = Math.abs(Number(openFlag) - 1);
	layer.confirm('您确认'+descStr+'攻略类型吗？', {
		btn: ['确认', '取消']  
	},
	function(){
		if (rowId == null || rowId == "") {
    		layer.msg("id不能为空!");
    		return;
    	}
    	$.post(JSSTRATEGYV1 + "/raiderType/updateOpenFlag?rowId="+rowId+"&openFlag="+openFlag+"&token="+sessionStorage.getItem("token"),null,function(json){
            if (json == 1) {
                layer.msg(descStr+"成功", {icon: 1});
                findData();
            } else if(json == "-2"){
                window.location.href= JSCTX;
            } else {
                layer.msg(descStr+"失败", {icon: 5});
            }
 	 	});
	},
	function(){
	   return;
	});
}
//删除游戏
function deleteRaiderType(rowId, openFlag){
    layer.confirm("您确认【删除】?", {btn: ['确认', '取消']},
        function(){
            $.ajax({
                url: JSSTRATEGYV1 + "/raiderType/delete",
                type: "post",
                cache: false,
                data: {rowId:rowId, openFlag:openFlag, token: sessionStorage.getItem("token")},
                dataType:"json",
                async:false,
                success: function(data) {
                    if (data == 1) {
                        layer.msg("删除成功", {icon: 1});
                        findData();
                    } else if (data == 2) {
                        layer.msg("删除失败");
                    } else if (data == 3) {
                        layer.msg("删除失败，该攻略类型启用中");
                    } else if (data == 4) {
                        layer.msg("删除失败，该攻略类型下有启用中攻略小类");
                    } else if(data == "-2"){
                        window.location.href=JSCTX;
                    } else {
                        layer.msg(data, {icon: 5});
                    }
                }
            });
        });
}
//查询
function findData(){
   $("#dataTable").bootstrapTable("refresh",{} ); 
} 

/*bootstrap table点击行事件*/
$(function(){
	 $("body").on("click","table>tbody>tr",function(){
      $(this).css("background","#e1ecf1").siblings().css("background","");
   });
});